<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require_once(dirname(__FILE__) . "/../common/Logger.php");
require_once(dirname(__FILE__) . "/../common/Common.php");
require_once(dirname(__FILE__) . "/../dbcom/OrderCom.php");
require_once(dirname(__FILE__) . "/../dbcom/ReservetimeCom.php");
require_once(dirname(__FILE__) . "/../dbcom/RagionCom.php");
require_once(dirname(__FILE__) . "/../dbcom/UsertypeCom.php");
require_once(dirname(__FILE__) . "/../dbcom/ServiceCom.php");
require_once(dirname(__FILE__) . "/../dbcom/StaisCom.php");

$log = new Logger("./../staisapi.log");
$common = new Common();
$ordercom = new OrderCom();
$reservetimecom = new ReservetimeCom();
$ragioncom = new RagionCom();
$usertypecom = new UsertypeCom();
$servicecom = new ServiceCom();
$staiscom = new StaisCom();

if((!isset($_REQUEST['orderid'])||empty($_REQUEST['orderid'])) || (!isset($_REQUEST['satisfied'])||empty($_REQUEST['satisfied'])) ||(!isset($_REQUEST['des'])||empty($_REQUEST['des']))){
    echo json_encode(array("code" => 100, "msg" => "lose parameter"));
    exit();
}

$orderid = $_REQUEST['orderid'];
$satisfied = $_REQUEST['satisfied'];
$des = $_REQUEST['des'];

$staisid = $staiscom->addStais($satisfied, $des);
if(!$staisid){
    echo json_encode(array("code" => 400, "msg" => "addstais failed"));
    exit();
}

$addstaisres = $ordercom->addStaisById($orderid, $staisid);
if(!$addstaisres){
    echo json_encode(array("code" => 400, "msg" => "order changestatis failed"));
    exit();
}

echo json_encode(array("code"=>0,"msg"=>"success"));
exit();